package com.xjc.business.controller.colladmin;

import com.xjc.business.service.CollegesService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-01-29 10:37
 */
@RestController
@RequestMapping("/college_admin/college")
public class CollegeController {

    @Autowired
    CollegesService collegesService;

    /**
     * 获取学校-学院名称
     * @param id 学院id
     * @return 学院名称
     */
    @GetMapping("/getCollegeName/{id}")
    public Result<String> getCollegeName(@PathVariable(value = "id",required = false) Integer id) {
        if (id == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return collegesService.getCollegeName(id);
    }
}
